package com.jinzhi.common.wxpay.utils;

import com.wechat.pay.java.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;

import java.security.PrivateKey;

/**
 * @Author: mcf
 * @CreateTime: 2024/05/16
 * @Description: MtWeChatConstant
 */
public class MtWeChatConstant {

    //商户号  (自己商户平台的商户号)
    public static final String MERCHANT_ID = "1579120381";
    //商户API私钥路径
    public static final String MERCHANT_PRIVATE_KEY_PATH = "/apiclient_key.pem";
    //商户证书序列号(自己配置的证书序列号)
    public static final String MERCHANT_SERIAL_NUMBER = "2E5196971788695351F785FC28E95A69AB2F766F";
    //商户APIV3密钥(自己配置的APIV3)
    public static final String API_V3_KEY = "12365436JZWYHUNANK11234562356121";
    //支付完成后的回调的地址(如果不要回调信息,可以不配置)
//    public static final String PAY_NOTIFY_URL = "https://xxxx.xxxx.com/services/mt/api/pay/notifi";
    //退款完成后的回调的地址(如果不要回调信息,可以不配置)
//    public static final String REFUND_NOTIFY_URL = "http://zhifu111.w1.luyouxia.net/api/wx-pay/refunds/notifys";
    public static final String REFUND_NOTIFY_URL = "https://jinzhijz.jz1x.com/api/wx-pay/refunds/notifys";
    //一下代码用于生成签名,写法参考微信支付文档,链接:https://github.com/wechatpay-apiv3/wechatpay-java/blob/main/core/src/test/java/com/wechat/pay/java/core/model/TestConfig.java
    public static final PrivateKey MERCHANT_PRIVATE_KEY;
    public static final String MERCHANT_PRIVATE_KEY_STRING;

    static {
        try {
            MERCHANT_PRIVATE_KEY_STRING = IOUtil.loadStringFromPath(MERCHANT_PRIVATE_KEY_PATH);
            MERCHANT_PRIVATE_KEY = PemUtil.loadPrivateKeyFromString(MERCHANT_PRIVATE_KEY_STRING);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
